<script setup lang="ts">
import { ref } from 'vue'
import { get } from '@/utils/service'
import { VUE_APP_BASE_API } from '@/utils/baseConfig'
import PointDataComponent from '@/components/PointDataComponent.vue'
import { showFailToast } from 'vant'
const showSignDialog = ref(false)
const active = ref('all')
const member = ref({})
const enterpriseBaseSet = ref({})
const piontRule =ref(VUE_APP_BASE_API+'/img/mina/pointRule.jpg')
queryMember()
queryEnterpriseSetMember();
function onClickLeft() {
  window.history.back()
}
function onClickTag(obj: object) {
  active.value = obj.name
}
function queryMember() {
  get('/memberWechatNew/queryMinaUserCenter', {}).then((res) => {
    if (res.code == 0) {
      member.value = res.data
    } else {
      showFailToast('无会员信息')
    }
  })
}
function queryEnterpriseSetMember() {
  get('/enterpriseBaseSetWechatNew/queryWechat', {}).then((res) => {
    if (res.code == 0) {
       enterpriseBaseSet.value = res.data
      piontRule.value=VUE_APP_BASE_API+enterpriseBaseSet.value.pointRoleDesImage
    } else {
      showFailToast('无会员信息')
    }
  })
}
</script>
<template>
  <van-nav-bar title="我的积分" left-text="返回" left-arrow @click-left="onClickLeft" />
    <div class="myPointDes">
      <h2 style="">
        可用积分:<span>{{ member.overagePiont }}</span
        >积分
      </h2>
      <p class="roleRule" @click="showSignDialog = true">积分规则?</p>
    </div>
    <van-tabs
      v-model:active="active"
      type="card"
      style="width: 100%"
      title-active-color="#FFF"
      color="#c82030"
      title-inactive-color="#c82030"
      @click-tab="onClickTag"
      sticky
    >
      <van-tab title="全部" name="all">
          <PointDataComponent :active="active"></PointDataComponent>
        </van-tab>
      <van-tab title="获得积分" name="add">
        <PointDataComponent :active="active"></PointDataComponent>
      </van-tab>
      <van-tab title="使用积分" name="used">
        <PointDataComponent :active="active"></PointDataComponent>
      </van-tab>
    </van-tabs>

  <br />
  <van-popup closeable v-model:show="showSignDialog" position="bottom" round :style="{height: '80%'}">
    <div class="mainContent">
      <img :src="piontRule" style="padding: 40px 12px;width: 100%;border-radius: 12px;"></img>
    </div>
  </van-popup>
</template>
